import numpy as np

#A为系数矩阵
A=np.array([[10,-1,-2],[-1,10,-2],[-1,-1,5]])
#b为常数矩阵
b=np.array([72,83,42])
#A的逆矩阵
inv_A=np.linalg.inv(A)
#A的逆矩阵与b做点积运算
x=inv_A.dot(b)
#5,6两行也可以用本行代替
#x=np.linalg.solve(A,b)
print(x)


from sympy import symbols,Eq,solve
x,y,z=symbols("x y z")
eqs=[Eq(10*x-y-2*z,72),
     Eq(-x+10*y-2*z,83),
     Eq(-x-y+5*z,42)]
print(solve(eqs,[x,y,z]))


